<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>修改路径信息</legend>
</fieldset>

<form class="layui-form" action="" lay-filter="Car">
    <INPUT name="id" type="hidden">
    <div class="layui-form-item">
        <label class="layui-form-label">图片路径</label>
        <button type="button" class="layui-btn" id="test1">
            <i class="layui-icon">&#xe67c;</i>上传图片
        </button>
        <br>
        <br>
        <label class="layui-form-label">图片类型</label>
        <div class="layui-input-block">
            <input type="number" name="tptype" lay-verify="required" autocomplete="off" placeholder="请输入路径类型(1~5)" class="layui-input">
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
</form>
<script>
    layui.use('upload', function(){
        var upload = layui.upload;
        //执行实例
        var uploadInst = upload.render({
            elem: '#test1' //绑定元素
            ,url: '/upload/' //上传接口
            ,done: function(res){
                //上传完毕回调
            }
            ,error: function(){
                //请求异常回调

            }
        });
    });
    layui.use(["jquery","form"],function () {
        var $=layui.jquery,form=layui.form;
        form.on('submit(demo1)', function(data){//提交按钮
            $.ajax({
                url:"/Car/updateCar",
                data:data.field,
                dataType:"json",
                type:"post",
                success:function (msg) {
                    if (msg.code==0){
                        tableIns.reload({
                            page:{
                                curr:1
                            }
                        });
                        layer.msg(msg.msg);//提示后台传过来的信息
                        layer.close(openIndex);//关闭当前页面
                    }else {
                        layer.msg(msg.msg);//提示后台过来的信息
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
        form.verify({
            username: function (value, item) { //value：表单的值、item：表单的DOM对象
                if (!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)) {
                    return '用户名不能有特殊字符';
                }
                if (/(^\_)|(\__)|(\_+$)/.test(value)) {
                    return '用户名首尾不能出现下划线\'_\'';
                }
                if (/^\d+\d+\d$/.test(value)) {
                    return '用户名不能全为数字';
                }
            }
        });
    });
</script>